//
//  SubView.m
//  TTDT_1
//
//  Created by lanou on 15/9/8.
//  Copyright (c) 2015年 zhengyl. All rights reserved.
//

#import "SubView.h"
#import "Define.h"
#import "UIView+Frame.h"

@interface SubView ()

@property (nonatomic, strong) UIImageView *bgImage;//背景图
@property (nonatomic, strong) UIImageView *btnImage;//按钮图标
@property (nonatomic, strong) UILabel *label;//标题

@end

@implementation SubView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    
    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    
    if (self) {
        
        //圆角
        self.layer.cornerRadius = width / 3.5;
        self.clipsToBounds = YES;//裁剪
        
        //背景图
        self.bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
        [self addSubview:self.bgImage];
        
        //按钮图标
        self.btnImage= [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 30, 30)];
        self.btnImage.center = CGPointMake(self.btnImage.width / 2 + 10, height / 2);
        [self addSubview:self.btnImage];
        
        //标题
        self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, self.btnImage.height, width, 30)];
        self.label.textColor = [UIColor whiteColor];
        [self.btnImage addSubview:self.label];
        
    }
    
    return self;
}

//使用此方法可一步完成初始化设置
- (void)setBgImage:(UIImage *)bgImage btnImage:(UIImage *)btnImage label:(NSString *)label {
    
    self.bgImage.image = bgImage;
    self.btnImage.image = btnImage;
    self.label.text = label;
    
}



@end
